package com.nitor.group.rsa;

import com.chilkatsoft.*;

public class ChilkatExample {
	
	static {
	   try {
	    
	    	System.loadLibrary("chilkat");
	    } catch (UnsatisfiedLinkError e) {
	      System.err.println("Native code library failed to load.\n" + e);
	      System.exit(1);
	   }
	  }
	
	 public static void main(String argv[])
	  {
	    CkEmail email = new CkEmail();

	    boolean success;

	    //  Add a PFX (or .p12) to be used for decryption
	    success = email.AddPfxSourceFile("/Users/SandeepBhanoori/downloads/Certs/NitorCertPassword.p12","/Users/SandeepBhanoori/downloads/Certs/NitorPrivKeyPassword.p12");
	    if (success != true) {
	        System.out.println(email.lastErrorText());
	        return;
	    }

	    //  Loading the .eml automatically decrypts.
	    success = email.LoadEml("/Users/SandeepBhanoori/downloads/Certs/Earth2NitorEncryptedSigned.eml");
	    if (success != true) {
	        System.out.println(email.lastErrorText());
	        return;
	    }

	    //  The email now exists as it was prior to encryption.
	    //  Your app may access the email's subject, body, attachments,
	    //  etc. using the Chilkat Email API...

	    //  Save the decrypted email:
	    success = email.SaveEml("decrypted.eml");
	    if (success != true) {
	        System.out.println(email.lastErrorText());
	        return;
	    }

	    System.out.println("Success.");

	  }// End of Main
	} // End of Class


